package com.unsins.web;

import com.unsins.business.domain.system.SysConstant;
import com.unsins.core.session.SessionManagerUtils;
import com.unsins.services.ISysConstantService;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by IntelliJ IDEA.
 * User: odpsoft
 * Date: 2009-4-21
 * Time: 16:49:39
 */
public class IndexController extends AbstractController {
    private SessionManagerUtils sessionManager;
    private ISysConstantService contantService;

    public void setSyscontantService(ISysConstantService service) {
        contantService = service;
    }

    public void setSessionManager(SessionManagerUtils session) {
        sessionManager = session;
    }

    protected ModelAndView handleRequestInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        String sessionValue = httpServletRequest.getParameter("sessionvalue");
        SysConstant constant = contantService.getSysConstantById(new Long(6401));
        sessionManager.setSessionAttribute(httpServletRequest, sessionValue);
        Map<String, SysConstant> model = new HashMap<String, SysConstant>();

        model.put("constant", constant);
        ModelAndView mav = new ModelAndView("home", model);
        return mav;
    }

}
